<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>javascript脚本语言</title>
</head>

<body>
    <h1> javaScript 之树</h1>

    <a href="www.taobao.com" target="_blank" name="taobao">淘宝</a>
    <a href="www.jd.com" target="_blank" class="jd">京东</a>
    <a href="www.pingduo.com" target="_blank" id="pingduoduo">拼多多</a>
    <a href="http://www.baidu.com">百度</a>
    <a></a>
    <!-- <button onclick="alert(document.getElementsByTagName('a').length)">A标签的个数</button> -->
    <button class="btn1">A标签的个数</button>
    <!-- <button onclick="alert(document.getElementsByName('taobao')[0].innerText)">淘宝名字</button> -->
    <button class="btn2">淘宝名字</button>

    <!-- <button onclick="alert(document.getElementsByTagName('a')[0])" class="btn3">淘宝链接</button> -->
    <button class="btn3">淘宝链接</button>
    <button id="btn">按钮</button>
</body>
<script>
    /* alert(document.title)
                                    var h1 =document.getElementsByTagName("h1")
                                    alert(h1[0].innerText) */
    var btn = document.querySelector("#btn")
    btn.onclick = function() {
        console.log(1)
    }
    var btn3 = document.querySelector(".btn3")
    btn3.onclick = () => {
        alert(3)
    }
    var btn2 = document.querySelector(".btn2")
    var taobao = document.querySelector("[name='taobao']")
        // console.log(taobao);
        // console.log(taobao.innerText);
    btn2.onclick = () => {
        console.log(1);
        alert(taobao.innerText)
    }

    var btn1 = document.querySelector(".btn1")
    var num = document.querySelectorAll("a")
    btn1.onclick = () => {
        alert(num.length)
    }
</script>

</html>